<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>抖音详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="./layui/css/layui.css">
    <style>
        .layui-form-label{
            width: 90px;
        }
    </style>
</head>

<body>
<script src="./layui/layui.js"></script>
<script type="text/html" id="toolbarDemo" >
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">讲师名</label>
            <div class="layui-input-block">
                <select id="name" name="name" >
                </select>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">创建时间</label>
            <div class="layui-input-inline">
                <input type="text" name="createTime"id="createTime"  autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label">电话号码</label>
            <div class="layui-input-inline">
                <input type="text" name="telephone"  id="telephone" autocomplete="off" class="layui-input">
            </div>
        </div>
        <button class="layui-btn" lay-event="query">查找</button>
        <button class="layui-btn" lay-event="flush">清空</button>

    </div>
</script>

<table class="layui-hide" id="jiangshitable" lay-filter="jiangshitable"></table>

<script th:inline=none>
    var optiondata
    layui.use(['table', 'dropdown','laydate'], function () {
        var table = layui.table;
        var laydate = layui.laydate;
        var $=layui.$;
        var count=0;
        var ctime="";
        var te="";
        let m = 10;
        function increment() {
            m ++;
        }
        setInterval(increment, 1000);
        table.render({
            elem: '#jiangshitable',
            id:'table1'
            , url: '/dydatareception/jiangshioutside'
            , response: {
                statusCode: 10000 //规定成功的状态码，默认：0
            },
            limit:20,
            limits:[20],
            height: 'full-0'
            , toolbar: '#toolbarDemo'
            , cellMinWidth: 82
            , page: true
            , cols: [[
                {field: 'name',  title: '讲师名'}
                , {field: 'create_time',  title: '创建时间'}
                , {field: 'phone_number', title: '电话号码'}
            ]]
            , error: function (res, msg) {
                console.log(res, msg)
            }
            , parseData: function (res) {
                console.log(res.data);
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.list //解析数据列表
                };
            },

        });
        laydate.render({
            elem: '#createTime'
        });
        $.ajax({
            url: '/ksdatareception/outsidejiangshiname',
            dataType: 'json',
            type: 'post',
            success: function (data) {
                $.each(data.data, function (index, item) {
                    $('#name').append(new Option(item.name,item.idnum));// 下拉菜单里添加元素
                });
                layui.form.render("select");
            }, error: function () {
                alert("仓库列表加载失败")
            }}
        )
        table.on('toolbar(jiangshitable)', function(obj){

            switch(obj.event){

                case 'query':
                    if(m<=1){
                        layer.msg("请不要频繁查询");
                        return;
                    }
                    var name= $('#name option:selected').text()
                    count=$('#name option:selected').val()
                    var createTime= $('input[name="createTime"]').val()
                    ctime=createTime
                    var telephone= $('input[name="telephone"]').val()
                    te=telephone;
                    table.reload('table1', {
                        where:{
                            name: name,
                            telephone: telephone,
                            createTime:createTime,
                        }
                    });
                    m=0;
                    laydate.render({
                        elem: '#createTime'
                    });
                    $.ajax({
                        url: '/dydatareception/outsidejiangshiname',
                        dataType: 'json',
                        type: 'post',
                        success: function (data) {
                            $.each(data.data, function (index, item) {
                                $('#name').append(new Option(item.name,item.idnum));// 下拉菜单里添加元素
                            });
                            layui.form.render("select");
                            $('#name').val(count);
                            $('#createTime').val(ctime);
                            $('#telephone').val(telephone);
                        }, error: function () {
                            alert("仓库列表加载失败")
                        }}
                    )
                    break;
                case 'flush':
                    location.reload();
                    break;
            }
        });

    });

</script>

</body>
</html>